package com.smart.manager.system.entities.models;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.smart.common.entities.core.BaseLongModel;
import com.smart.common.entities.domain.DataScope;
import com.smart.manager.system.entities.enums.AccountState;
import com.smart.manager.system.entities.enums.AccountType;
import com.smart.manager.system.entities.enums.Sex;
import com.smart.manager.system.entities.views.DeptView;
import com.smart.manager.system.entities.views.OrganView;
import io.ebean.annotation.DbArray;
import io.ebean.annotation.DbJson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 系统管理-接口功能
 * system_api
 * @author Administrator
 */
@EqualsAndHashCode(callSuper = true)
@Entity
@Data
@Accessors(chain = true)
public class SystemAccount extends BaseLongModel {

    /**
     * 登录账号
     */

    @ApiModelProperty("登录账号")
    private String account;
    /**
     * 用户真实姓名
     */

    @ApiModelProperty("用户真实姓名")
    private String name;
    /**
     * 操作员性别 1=男 2=女 3=未知
     */

    @ApiModelProperty("操作员性别")
    private Sex sex;
    /**
     * 登录密码
     */

    @ApiModelProperty("登录密码")
    @JsonIgnore
    private String password;
    /**
     * 头像地址
     */

    @ApiModelProperty("头像地址")
    private String avatar;
    /**
     * 角色代码集合
     */

    @ApiModelProperty("角色代码集合")
    @DbArray
    private List<String> roleCodes;
    /**
     * 登录手机
     */

    @ApiModelProperty("手机号码")
    private String phoneNumber;
    /**
     * 登录邮箱
     */

    @ApiModelProperty("登录邮箱")
    private String email;
    /**
     * QQ号码
     */

    @ApiModelProperty("QQ号码")
    private String qq;
    /**
     * 微信号码
     */

    @ApiModelProperty("微信号码")
    private String wechat;


    /**
     * 账号状态 枚举
     */

    @ApiModelProperty("账号状态")
    private AccountState state;


    /**
     * 上次访问系统的时间
     */
    @ApiModelProperty("上次访问系统的时间")
    private LocalDateTime lastVisitTime;
    /**
     * 上次修改密码的时间
     */
    @ApiModelProperty("上次修改密码的时间")
    private LocalDateTime lastPassTime;


    @ApiModelProperty("角色名称列表")
    private transient List<String> roleNames;

    @ApiModelProperty("机构数据范围")
    @DbJson
    private DataScope dataScope;


    @ApiModelProperty("账号类型")
    private AccountType accountType;



    @ApiModelProperty("所属机构")
    @ManyToOne
    @JoinColumn(name = "organ" ,referencedColumnName = "code")
    private OrganView organ;


    @ApiModelProperty("所属机构")
    @ManyToOne
    @JoinColumn(name = "dept" ,referencedColumnName = "code")
    private DeptView dept;


}
